< previous page page_123 next page >

Page 123
Table 6.4 Variable Naming Standards.
Data TypeSample NamesDefault Values
BooleanboolPerformFalse
BytebytValue0
DatedtEntryDecember 30, 1899; 12:00:00 AM
IntegerintLoop0
LonglngAmount0
SinglesngAmount0
DoubledblValue0
CurrencycurChkAmt0
StringstrCompany""
VariantvntVar1Empty

9f31265bb40b592b1929e18a47ab28e5.gif
TIP
Always use Hungarian Notation when naming variables. This will make your variable names much more descriptive and will make your programs easier to read. If you are not familiar with Hungarian Notation please refer to Appendix A of this book.
Scope Prefixes
As you saw in the previous examples, the scope of the variable is used as a modifier to the name of the variable. For Public variables, you use the letter g, which stands for Global. The reason for this is because the keyword Public was not introduced until Visual Basic 4, and most people had already adopted the standard prefix g for the old declaration Global.
The prefix m is added to the names of all module-level variables declared in the (General) (Declarations) section. No prefix is used for local variables in a procedure.
The Variant Data Type
The Variant data type allows you to store any type of data in a variable. This variable can change its type at any time. When it does, Visual Basic takes care of all the housekeeping chores. Because its such a flexible data type, it carries much more overhead (memory and resources) than a normal data type. Therefore, you should only use the Variant data type as a last resort.

 
< previous page page_123 next page >

If you like this book, buy it!